// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sys

import (
	"context"
	"hotgo/api/admin/wxuser"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	WxUser = cWxUser{}
)

type cWxUser struct{}

// List 查看小程序用户列表
func (c *cWxUser) List(ctx context.Context, req *wxuser.ListReq) (res *wxuser.ListRes, err error) {
	list, totalCount, err := service.SysWxUser().List(ctx, &req.WxUserListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.WxUserListModel{}
	}

	res = new(wxuser.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出小程序用户列表
func (c *cWxUser) Export(ctx context.Context, req *wxuser.ExportReq) (res *wxuser.ExportRes, err error) {
	err = service.SysWxUser().Export(ctx, &req.WxUserListInp)
	return
}

// Edit 更新小程序用户
func (c *cWxUser) Edit(ctx context.Context, req *wxuser.EditReq) (res *wxuser.EditRes, err error) {
	err = service.SysWxUser().Edit(ctx, &req.WxUserEditInp)
	return
}

// View 获取指定小程序用户信息
func (c *cWxUser) View(ctx context.Context, req *wxuser.ViewReq) (res *wxuser.ViewRes, err error) {
	data, err := service.SysWxUser().View(ctx, &req.WxUserViewInp)
	if err != nil {
		return
	}

	res = new(wxuser.ViewRes)
	res.WxUserViewModel = data
	return
}

// Delete 删除小程序用户
func (c *cWxUser) Delete(ctx context.Context, req *wxuser.DeleteReq) (res *wxuser.DeleteRes, err error) {
	err = service.SysWxUser().Delete(ctx, &req.WxUserDeleteInp)
	return
}

// Status 更新小程序用户状态
func (c *cWxUser) Status(ctx context.Context, req *wxuser.StatusReq) (res *wxuser.StatusRes, err error) {
	err = service.SysWxUser().Status(ctx, &req.WxUserStatusInp)
	return
}